package com.rmy.publish.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.rmy.common.annotation.Log;
import com.rmy.common.core.controller.BaseController;
import com.rmy.common.core.domain.AjaxResult;
import com.rmy.common.enums.BusinessType;
import com.rmy.publish.domain.MipsPageInfo;
import com.rmy.publish.service.IMipsPageInfoService;
import com.rmy.common.utils.poi.ExcelUtil;
import com.rmy.common.core.page.TableDataInfo;

/**
 * 页面信息Controller
 * 
 * @author rmy
 * @date 2023-05-26
 */
@RestController
@RequestMapping("/publish/mipsPageInfo")
public class MipsPageInfoController extends BaseController
{
    @Autowired
    private IMipsPageInfoService mipsPageInfoService;

    /**
     * 查询页面信息列表
     */
    @PreAuthorize("@ss.hasPermi('publish:mipsPageInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(MipsPageInfo mipsPageInfo)
    {
        startPage();
        List<MipsPageInfo> list = mipsPageInfoService.selectMipsPageInfoList(mipsPageInfo);
        return getDataTable(list);
    }

    /**
     * 导出页面信息列表
     */
    @PreAuthorize("@ss.hasPermi('publish:mipsPageInfo:export')")
    @Log(title = "页面信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MipsPageInfo mipsPageInfo)
    {
        List<MipsPageInfo> list = mipsPageInfoService.selectMipsPageInfoList(mipsPageInfo);
        ExcelUtil<MipsPageInfo> util = new ExcelUtil<MipsPageInfo>(MipsPageInfo.class);
        util.exportExcel(response, list, "页面信息数据");
    }

    /**
     * 获取页面信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('publish:mipsPageInfo:query')")
    @GetMapping(value = "/{pageId}")
    public AjaxResult getInfo(@PathVariable("pageId") Long pageId)
    {
        return AjaxResult.success(mipsPageInfoService.selectMipsPageInfoByPageId(pageId));
    }

    /**
     * 新增页面信息
     */
    @PreAuthorize("@ss.hasPermi('publish:mipsPageInfo:add')")
    @Log(title = "页面信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MipsPageInfo mipsPageInfo)
    {
        return toAjax(mipsPageInfoService.insertMipsPageInfo(mipsPageInfo));
    }

    /**
     * 修改页面信息
     */
    @PreAuthorize("@ss.hasPermi('publish:mipsPageInfo:edit')")
    @Log(title = "页面信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MipsPageInfo mipsPageInfo)
    {
        return toAjax(mipsPageInfoService.updateMipsPageInfo(mipsPageInfo));
    }

    /**
     * 删除页面信息
     */
    @PreAuthorize("@ss.hasPermi('publish:mipsPageInfo:remove')")
    @Log(title = "页面信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{pageIds}")
    public AjaxResult remove(@PathVariable Long[] pageIds)
    {
        return toAjax(mipsPageInfoService.deleteMipsPageInfoByPageIds(pageIds));
    }
}
